home *** CD-ROM | disk | FTP | other *** search
/ C/C++ Users Group Library 1996 July / C-C++ Users Group Library July 1996.iso / listings / v_13_06 / vancamp / tdnorm.hpp < prev   
Encoding:
C/C++ Source or Header  |  1995-02-02  |  1.0 KB  |  37 lines

  1. // tdnorm.hpp: TableDataNormalize class (LISTING 2)
  2. #ifndef TDNORM_HPP
  3. #define TDNORM_HPP
  4. #include "tbldata.hpp"
  5.  
  6. // (Note that cellType class must have SetValue() and
  7. // GetValue() methods, and a copy constructor.)
  8. template <class cellType> class TableDataNormalize:
  9.         public TableData<cellType>
  10. {
  11. public:
  12.     TableDataNormalize (TableData<cellType> *const
  13.             prev): TableData<cellType> (prev)
  14.     { }
  15.  
  16.     virtual const cellType GetCell (const int row,
  17.             const int col)
  18.     {
  19.         assert (PrevTD != 0);
  20.         cellType cell (PrevTD->GetCell (row, col));
  21.         cell.SetValue ( cell.GetValue() /
  22.                 (PrevTD->GetCell (0, col)).GetValue());
  23.         return (cell);
  24.     }
  25.  
  26.     virtual void PutCell (const int row, const int col,
  27.             const cellType &value)
  28.     {
  29.         assert (PrevTD != 0);
  30.         cellType cell (value);
  31.         cell.SetValue ( cell.GetValue() *
  32.                 (PrevTD->GetCell (0, col)).GetValue());
  33.         PrevTD->PutCell (row, col, cell);
  34.     }
  35. };
  36. #endif
  37.